package net.sunofbeach.service;

import com.alipay.easysdk.factory.Factory;
import com.alipay.easysdk.payment.app.models.AlipayTradeAppPayResponse;
import com.alipay.easysdk.payment.page.models.AlipayTradePagePayResponse;
import net.sunofbeach.util.OrderUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.annotation.OrderUtils;
import org.springframework.stereotype.Service;

@Service
public class PayService {

    @Value("${alipay.notifyUrl}")
    private String returnUrl;

    public Object pay() throws Exception {
        //web
//        AlipayTradePagePayResponse response = Factory.Payment.Page().pay(
//                "测试订单", OrderUtil.getOrderNo(),"10.50",returnUrl
//        );

        //app  没有回调页面 需要android 来控制跳转支付宝付款界面
        //得到字符串返回给客户端
        AlipayTradeAppPayResponse response = Factory.Payment.App().pay(
                "测试订单", OrderUtil.getOrderNo(),"10.50"
        );

        return  response.body;
    }
}
